//
//  HttpTool.m
//  微博2期
//
//  Created by J on 15/12/20.
//
//

#import "HttpTool.h"
#import "AFNetworking.h"
@implementation HttpTool


+ (void)get:(NSString *)url params:(NSDictionary *)params success:(void (^)(id))success fail:(void (^)(NSError * error))fail{
    
    //1.请求管理者
    AFHTTPRequestOperationManager * manager= [AFHTTPRequestOperationManager manager];
    //2.发送请求
    [manager POST:url parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) {
        
        if (success) {
            success(responseObject);
        }
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        
        if (error) {
            fail(error);
        }
        
    }];
    
    
}

+ (void)post:(NSString *)url params:(NSDictionary *)params success:(void (^)(id))success fail:(void (^)(NSError * error))fail{
    
    //1.请求管理者
    AFHTTPRequestOperationManager * manager= [AFHTTPRequestOperationManager manager];
    //2.发送请求
    [manager POST:url parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) {
        
        if (success) {
            success(responseObject);
        }
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        
        if (error) {
            fail(error);
        }

    }];
  
    
}
@end
